package ecoiot.com.testproject.webview;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.BaseAdapter;

import ecoiot.com.testproject.R;

/**
 * Created by developer on 17-8-21.
 */

public class TestWebViewActivity extends AppCompatActivity {

    private TestViewPager viewPager;
    private TestWebView webView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_webview);

        webView = (TestWebView) findViewById(R.id.activity_test_webview_wv);
        webView.loadUrl("http://mobile.sina.cn/?from=wap");

       /* viewPager = (TestViewPager) findViewById(R.id.activity_test_webview_vp);
        viewPager.setAdapter(new MyAdapter());*/
    }


    private class MyAdapter extends PagerAdapter {

        @Override
        public int getCount() {
            return 4;
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            TestWebView webView = new TestWebView(TestWebViewActivity.this);
//            webView.
            webView.loadUrl("http://mobile.sina.cn/?from=wap");
            webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
            container.addView(webView);
            return webView;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
//            super.destroyItem(container, position, object);
//            container.removeView((View) object);
        }

    }
}
